import Jenkins from "jenkins";
const jenkins = new Jenkins({
  baseUrl: "http://renren.wang:11466da61615b38b55605754668db88162@jenkins.ebonex.io",
});

async function main() {
  try {
    const res0 = await jenkins.job.get("global-dev-broker/global-dev-otc-client");
    console.log(res0)
    const res = await jenkins.job.get("global-dev-broker/global-dev-otc-client");
    const allValueItems = res.actions[0].parameterDefinitions[0]['allValueItems']?.values
    console.log("allValueItems====>", allValueItems)
    console.log("res1====>", {
      name: "global-dev-broker/global-dev-otc-client",
      branchName: allValueItems?.[3]?.value
    })
    const res1 = await jenkins.job.build({
      name: "global-dev-broker/global-dev-otc-client",
      parameters: { branchName: allValueItems?.[3]?.value }
    });
    console.log("res1====>", res1)

    // const log = jenkins.build.logStream("global-dev-broker/global-dev-otc-client", 112);

    // log.on("data", (text) => {
    //   process.stdout.write(text);
    // });

    // log.on("error", (err) => {
    //   console.log("error", err);
    // });

    // log.on("end", () => {
    //   console.log("end");
    // });
  } catch (err) {
    console.log("报错了", err)
  };
}
main()